#include "lab5.h"

// see lab4.h
int main (int argc, char* argv[]) {
    
	testInts();
	testFloats();
	testChars();
	
	testBooks();
	testFrames();
}

// see lab4.h
void testBooks() {
	cout << "\nTesting Books functionality\n";
	Stack<Book>* stack = new Stack<Book>(4);

	// Prime the stack
	stack->push(*new Book("Chimarvamidium", 668));
	stack->push(*new Book("Five Songs of King Wulfharth", 1132));
	stack->push(*new Book("Herbane's Bestiary: Automatons", 874));

	cout << "Expecting false from isEmpty: " << stack->isEmpty() << "\n";	
	
	stack->pop();
	stack->pop();

	stack->push(*new Book("Last King of the Ayleids", 1077));
	Book val = stack->pop();	
	cout << "Expecting 'Last King of the Ayleids', popped value was: \n  " << val << "\n";
	
	val = stack->peek();	
	cout << "Expecting Chimarvamidium, top of the stack is: \n  " << val << "\n";
	
	stack->pop();
	
	cout << "Expecting true from isEmpty: " << stack->isEmpty() << "\n";	
	
	delete stack;	
}

// see lab4.h
void testFrames() {
	cout << "\nTesting Books functionality\n";
	Stack<Activation_Frame>* stack = new Stack<Activation_Frame>(4);

	// Prime the stack
	stack->push(*new Activation_Frame("getEntryPoint", "321", 123));
	stack->push(*new Activation_Frame("flashHyperscrew", "543", 345));
	stack->push(*new Activation_Frame("activateProcess", "765", 567));

	cout << "Expecting false from isEmpty: " << stack->isEmpty() << "\n";	
	
	stack->push(*new Activation_Frame("reclaimResources", "987", 789));
	Activation_Frame val = stack->pop();	
	cout << "Expecting 'reclaimResources', popped value was: \n  " << val << "\n";
	
	val = stack->peek();	
	cout << "Expecting activateProcess, top of the stack is: \n  " << val << "\n";
	
	stack->pop();
	stack->pop();
	stack->pop();
	
	cout << "Expecting true from isEmpty: " << stack->isEmpty() << "\n";	
	
	delete stack;	
}

// see lab4.h
void testInts() {
	cout << "\nTesting Integer functionality\n";
	Stack<int>* stack = new Stack<int>(5);

	// Prime the stack
	stack->push(1);
	stack->push(2);
	stack->push(3);
	stack->push(4);
	stack->push(5);

	cout << "Expecting false from isEmpty: " << stack->isEmpty() << "\n";	
	
	stack->pop();
	stack->pop();

	stack->push(4);
	int val = stack->pop();	
	cout << "Expecting 4, popped value was: " << val << "\n";
	
	val = stack->peek();	
	cout << "Expecting 3, top of the stack is: " << val << "\n";
	
	stack->pop();
	stack->pop();
	stack->pop();
	
	cout << "Expecting true from isEmpty: " << stack->isEmpty() << "\n";	
	
	delete stack;
}

// see lab4.h
void testChars() {
	cout << "\nTesting Chars functionality\n";
	Stack<char>* stack = new Stack<char>(8);

	// Prime the stack
	stack->push('d');
	stack->push('e');
	stack->push('a');
	stack->push('d');
	stack->push('b');
	stack->push('e');
	stack->push('e');
	stack->push('f');

	cout << "Expecting false from isEmpty: " << stack->isEmpty() << "\n";	
	
	stack->pop();
	stack->pop();
	stack->pop();

	stack->push('\t');
	char val = stack->pop();	
	cout << "Expecting tab character, popped value was: ." << val << ".\n";
	
	val = stack->peek();	
	cout << "Expecting b, top of the stack is: " << val << "\n";
	
	stack->pop();
	stack->pop();
	stack->pop();
	stack->pop();
	
	cout << "Expecting true from isEmpty: " << stack->isEmpty() << "\n";	
	
	delete stack;
}

// see lab4.h
void testFloats() {
	cout << "\nTesting Float functionality\n";
	Stack<float>* stack = new Stack<float>(6);

	// Prime the stack
	stack->push(1.0f);
	stack->push(2.2f);
	stack->push(3.4f);
	stack->push(4.6f);
	stack->push(5.9f);
	stack->push(6.1f);

	cout << "Expecting false from isEmpty: " << stack->isEmpty() << "\n";	
	
	stack->pop();
	stack->pop();

	val = stack->peek();	
	cout << "Expecting 4.6, top of the stack is: " << val << "\n";

	stack->push(4.85);
	float val = stack->pop();	
	cout << "Expecting 4.85, popped value was: " << val << "\n";
		
	stack->pop();
	stack->pop();
	stack->pop();
	stack->pop();
	
	cout << "Expecting true from isEmpty: " << stack->isEmpty() << "\n";	
	
	delete stack;
}